import { z } from 'zod';

const UserSchemas = {
    // 邮箱验证码
    emailCaptcha: z.object({
        query: z.object({
            email: z.string().email()
        })
    }),

    // 注册验证
    register: z.object({
        body: z.object({
            nickname: z.string(),
            email: z.string().email(),
            password: z.string().min(6),
            captcha: z.string()
        })
    }),

    // 登录验证
    login: z.object({
        body: z.object({
            account: z.string(),
            password: z.string(),
        })
    }),

    // 更新用户信息
    update: z.object({
        body: z.object({
            nickname: z.string().min(2).max(20).optional(),
            signature: z.string().max(100).optional(),
            area: z.string().max(50).optional(),
            gender: z.enum(['MALE', 'FEMALE', 'UNKNOWN']).optional()
        })
    }),

    // 获取用户信息
    getUserInfo: z.object({
        query: z.object({
            userId: z.string().regex(/^\d+$/)
        })
    }),

    //下载头像
    downloadAvatar: z.object({
        query: z.object({
            id: z.string(),
            isGroup: z.string()
        })
    })
};

export type EmailCaptchaInput = z.infer<typeof UserSchemas.emailCaptcha>['query'];
export type RegisterInput = z.infer<typeof UserSchemas.register>['body'];
export type LoginInput = z.infer<typeof UserSchemas.login>['body'];
export type UpdateUserInput = z.infer<typeof UserSchemas.update>['body'];
export type GetUserInfoInput = z.infer<typeof UserSchemas.getUserInfo>['query'];
export type DownloadAvatar = z.infer<typeof UserSchemas.downloadAvatar>['query'];


export default UserSchemas;